export function GetRequest(url, data) {
	const token = uni.getStorageSync('token')
	const header = {
		'content-type': 'application/json', //自定义请求头信息
	}
	if (token !== "") {
		header['authorization'] = token
	}
	return new Promise((resolve, reject) => {
		uni.request({
			url: url,
			method: 'GET',
			data: data,
			header: header,
			success: res => resolve(res),
			fail: err => reject(err)
		})
	})
}
export function PostJsonRequest(url, data) {
	const token = uni.getStorageSync('token')
	const header = {
		'content-type': 'application/json', //自定义请求头信息
	}
	if (token !== "") {
		header['authorization'] = token
	}
	return new Promise((resolve, reject) => {
		uni.request({
			url: url,
			method: 'POST',
			data: data,
			header: header,
			success: res => resolve(res),
			fail: err => reject(err)
		})
	})
}

export function PostFormRequest(url, data) {
	const token = uni.getStorageSync('token')
	const header = {
		'content-type': 'multipart/form-data', //自定义请求头信息
	}
	if (token !== "") {
		header['authorization'] = token
	}
	return new Promise((resolve, reject) => {
		uni.request({
			url: url,
			method: 'POST',
			data: data,
			header: header,
			success: res => resolve(res),
			fail: err => reject(err)
		})
	})
}

export function uploadImageRequest(url, data) {
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: url, // 上传图片的接口地址
			filePath: data.image, // 图片文件路径
			name: 'image', // 服务器接收的文件字段名
			success: res => resolve(res),
			fail: err => reject(err)
		});
	})
}